package com.qing.thread.create;

/**
 * 方式2：实现Runnable类，重写run方法，启动线程需要new Thread(new CreateThread2()).start();
 */
public class CreateThread2 implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println("我是通过实现Runnable类创建的线程：" + i);
        }
    }

    public static void main(String[] args) {
        CreateThread2 createThread2 = new CreateThread2();
        Thread thread = new Thread(createThread2);
        thread.start();

        //new Thread(new CreateThread2()).start();

        for (int i = 0; i < 20; i++) {
            System.out.println("我是Main方法输出：" + i);
        }
    }
}
